package com.lych.dubbo.api;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.lych.dubbo.mappers.QuestionMapper;
import com.lych.model.domain.Question;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;

@DubboService
public class QuestionApiImpl implements QuestionApi {

    @Autowired
    private QuestionMapper questionMapper;

    @Override
    /**
     * 获取用户的陌生人问题
     */
    public Question findById(Long userId) {
        LambdaQueryWrapper<Question> lqw = new LambdaQueryWrapper<>();
        lqw.eq(Question::getUserId,userId);
        return questionMapper.selectOne(lqw);
    }

    @Override
    /**
     * 设置陌生人问题 - 保存
     */
    public void save(Question question) {
        questionMapper.insert(question);
    }

    @Override
    /**
     * 设置陌生人问题 - 保存
     */
    public void update(Question question) {
        questionMapper.updateById(question);
    }



}
